package com.cloudcc.mobile.util;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

/**
 * Created by yipei.zhang on 2019/2/25.
 */
public class AppUtil {

    /**
     * 获取App的当前版本名称
     * @param context
     * @return
     */
    public static String getAppVersionName(Context context) {
        PackageManager manager = context.getPackageManager();
        String name = null;
        try {
            PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0);
            name = info.versionName;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }

        return name;
    }

    public static String getFileProviderAuthority(Context context){
        ApplicationInfo info = context.getApplicationInfo();
        if (info != null) {
            return info.packageName + ".FileProvider";
        }
        return "com.yundong.gongniu.FileProvider";
    }
}
